package com.hqbzl.c1.cass;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicStampedReference;
import java.util.stream.IntStream;

@Slf4j
public class TestAtomicStamperReference {
    public static void main(String[] args) {
        // 值和版本号
        AtomicStampedReference<String> asr = new AtomicStampedReference<>("a", 0);
        final int stamp = asr.getStamp();
        log.debug("stamp:{}", asr.getStamp());
        IntStream.range(0, 3).forEach(x -> {
            final boolean b = asr.compareAndSet("a", "b", stamp, stamp + 1);
            log.debug("b:{}", b);
            log.debug("stamp:{}", asr.getStamp());
            log.debug("after value:{}", asr.getReference());
        });


    }
}
